<?php
/**
 * @author all@cosmos-framework.org
 * @copyright (c) 2013 cosmos-framework.org
 * @license http://www.opensource.org/licenses/mit-license.php
 * @link http://cosmos-framework.org/
 * @package cosmos.framework
 * @version 2.0
 */
namespace Cosmos;

class Exception extends \Exception {

    /**
     * @param string $message
     * @param int $code
     * @param Exception $previous
     */
    public function __construct($message = null, $code = 0, $previous = null) {

        parent::__construct($message, self::_c($code), $previous);
    }

    /**
     * @param int $code
     * @return int
     */
    public function code($code = null) {

        return $code ? $this->code = self::_c($code) : $this->code;
    }

    /**
     * @param string $message
     * @return string
     */
    public function message($message = null) {

        return $message ? $this->message = $message : $this->message;
    }

    /**
     * @see http_response_code
     */
    private static function _c($code) {

        switch ($code) {

            case 100 :
                break;
            case 101 :
                break;
            case 200 :
                break;
            case 201 :
                break;
            case 202 :
                break;
            case 203 :
                break;
            case 204 :
                break;
            case 205 :
                break;
            case 206 :
                break;
            case 300 :
                break;
            case 301 :
                break;
            case 302 :
                break;
            case 303 :
                break;
            case 304 :
                break;
            case 305 :
                break;
            case 400 :
                break;
            case 401 :
                break;
            case 402 :
                break;
            case 403 :
                break;
            case 404 :
                break;
            case 405 :
                break;
            case 406 :
                break;
            case 407 :
                break;
            case 408 :
                break;
            case 409 :
                break;
            case 410 :
                break;
            case 411 :
                break;
            case 412 :
                break;
            case 413 :
                break;
            case 414 :
                break;
            case 415 :
                break;
            case 500 :
                break;
            case 501 :
                break;
            case 502 :
                break;
            case 503 :
                break;
            case 504 :
                break;
            case 505 :
                break;
            default :
                return 500;
        }

        return $code;
    }

}
